package cn.jingyuan.swan.gw.web.config;

import cn.jingyuan.swan.gw.service.AccessLogService;
import cn.jingyuan.swan.gw.web.filter.zuul.ZuulLogRecordFilter;
import cn.jingyuan.swan.gw.web.filter.zuul.ZuulSendErrorFilter;
import com.netflix.zuul.ZuulFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Slf4j
@Configuration
public class ZuulFilterConfig {

    @Resource
    AccessLogService accessLogService;

    /** 响应过滤器 */
    @Bean
    public ZuulFilter zuulLogRecordFilter() {
        return new ZuulLogRecordFilter(accessLogService);
    }

    /** 错误过滤器 */
    @Bean
    public ZuulFilter zuulSendErrorFilter() {
        return new ZuulSendErrorFilter(accessLogService);
    }

}
